import axios from './axios'
import qs from 'qs'


//获取供应商列表
export function getVendorList() {
    return axios.post('/supplier/manage/get_supplier_list.do').then(res=>Promise.resolve(res.data))
}

//获取员工列表
export function getEmployeeList() {
    const data = qs.stringify({pageSize:5000});
    return axios.post('/employee/manage/get_all_employee_list.do',data).then(res=>Promise.resolve(res.data))
}

//获取客户列表
export function getCustomerList() {
    return axios.get('/customer/manage/get_customer_list.do').then(res=>Promise.resolve(res.data))
}

//新增员工
export function addEmployee(employee) {
    const data = qs.stringify(employee);
    return axios.post('/employee/manage/save_base_information.do',data).then(res=>Promise.resolve(res.data))
}
export function modEmplyee(employee) {
    const data = qs.stringify(employee);
    return axios.post('/employee/manage/improve_information.do',data).then(res=>Promise.resolve(res.data))
}

//part database

export function getPartList() {
    return axios.post('/spare_parts/manage/get_list.do').then(res => {
        return Promise.resolve(res.data)
    }, (err) => {
        return Promise.reject(err)
    })
}

export function getPartDetail(sparePartsId) {
    return axios.post('/spare_parts/manage/get_spare_parts_detail.do',qs.stringify({sparePartsId})).then(res=>{
        return Promise.resolve(res.data)
    },err=>{
        return Promise.reject(err)
    })
    
}

export function modifyPart(part) {
    return axios.post('/spare_parts/manage/update_spare_parts.do',qs.stringify(part)).then(res=>{
        return Promise.resolve(res.data)
    },err=>{
        return Promise.reject(err)
    })

}
export function modQty({partId,quantity}) {
    return axios.post('/spare_parts/manage/update_parts_stock.do',qs.stringify({partId,quantity})).then(res=>Promise.resolve(res.data))
}


export function addPart(part) {
    return axios.post('/spare_parts/manage/add_spare_parts.do',qs.stringify(part)).then(res=>{
        return Promise.resolve(res.data)
    },err=>{
        return Promise.reject(err)
    })
}
export function getPartStockDetail(partsId) {
    return axios.post('/spare_parts/manage/update_parts_stock_detail.do',qs.stringify({partsId})).then(res=>Promise.resolve(res.data))
}


export function upLoadFile(formData) {
    return axios.post('/stock_change_record/excel_stock_in.do',formData,{
        headers:{'Content-Type':'multipart/form-data'}
    }).then(res=>Promise.resolve(res.data))
}
export function upLoadFiles(formData) {
    return axios.post('/file/uploadFileCDN',formData,{
        headers:{'Content-Type':'multipart/form-data'}
    }).then(res=>Promise.resolve(res.data))
}

export function userLogin({username,password}) {
    return axios.post('/user/login',qs.stringify({username,password})).then(res=>Promise.resolve(res.data))
}

export function checkInventory(formData) {
   //  pandian
    return axios.post('/stock_change_record/check_inventory.do',formData,{
        headers:{'Content-Type':'multipart/form-data'}
    }).then(res=>Promise.resolve(res.data))
}

export function getUniSystem() {
    return axios.get('/spare_parts/manage/select_system_name.do').then(res=>Promise.resolve(res.data))
}
export function getUniUnit() {
    return axios.get('/spare_parts/manage/select_host_num.do').then(res=>Promise.resolve(res.data))
}